package ${packageName};

<#list impImports as imports>
import ${imports};
</#list>
/**
 * ${tableName}
 */
public class ${d_tableName}Imp extends ${d_tableName}Cache{
	static Map<Integer,${d_tableName}Imp> imps = new HashMap<Integer,${d_tableName}Imp>();
	// 限时1s
	static final int GET_LOCK_TIME_OUT_1S = 1000;
	// 不加锁
	static final int NO_LOCK = -1;
	// 加锁(一直等待)
	static final int LOCK = 0;
	
	static{
		imps.put(GET_LOCK_TIME_OUT_1S,new ${d_tableName}Imp(true,1000));
		imps.put(NO_LOCK,new ${d_tableName}Imp());
		imps.put(LOCK,new ${d_tableName}Imp(true,0));
	}
	
	private ${d_tableName}Imp(){
		
	}
	
	private ${d_tableName}Imp(boolean isWriteLock,int lockTimeOut){
		setWriteLock(isWriteLock);
		setLockTimeout(lockTimeOut);
	}
	
	public static ${d_tableName}Imp asyn(){
		return imps.get(NO_LOCK);
	}
	
	public static ${d_tableName}Imp sync(int timeOut){
		${d_tableName}Imp imp = null;
		if(timeOut < 0)
			timeOut = GET_LOCK_TIME_OUT_1S;
		synchronized (imps) {
			imp = imps.get(timeOut);
			if(imp==null){
				imp = new ${d_tableName}Imp(true,timeOut);
				imps.put(timeOut,imp);
			}
		}
		return imp;
	}
	
	public static ${d_tableName}Imp sync(){
		return imps.get(LOCK);
	}
	
}